package thread;

/**
 * @author sjw
 * @className WaitNotify
 * @date 2021/3/21 11:02
 * @description: TODO
 */
public class WaitNotify {
    private static Object object=new Object();

    public static void main(String[] args) {
        Integer a=1;
        Integer b=-3;
        System.out.println(a+"-"+b);
        new Thread(){
            @Override
            public void run(){
                synchronized (object){
                    System.out.println("ahah");
                    try {
                        object.wait(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("ahah end");
                }
            }
        }.start();


        new Thread(){
            @Override
            public void run(){
                synchronized (object){
                    System.out.println("ahah1");
                    object.notify();
                    System.out.println("ahah1 end");
                }
            }
        }.start();

    }
}
